
package Listeners;

import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

import Model.Paper;

/**
 * 
 * @author William Kim
 * 
 * Borrowed code heavily from SubmitPaperPanel.UploadPaperListener.
 *
 */
public class UploadRecommendationListener extends AbstractAction
{
  
  final Paper myPaper;
  
  public UploadRecommendationListener(final Paper paper)
  {
    myPaper = paper;
  }
  public void actionPerformed(ActionEvent arg0)
  {
    JFileChooser recChooser = new JFileChooser();

    int returnVal = recChooser.showOpenDialog(null);

    if (returnVal == JFileChooser.APPROVE_OPTION)
    {

      myPaper.editRecommendation(recChooser.getSelectedFile());
      JOptionPane
      .showMessageDialog(null, "Recommendation Form has been submitted.");
    } else if (returnVal == JFileChooser.CANCEL_OPTION)
    {
      // Do Nothing & JFilechooser closes
    } else
      JOptionPane
          .showMessageDialog(null, "Error uploading Recommendation Form");
  }

}